3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
QuickDraw 3D provides routines that you can use to operate on quaternions.
You can use the Q3Quaternion_Set function to set the components of a quaternion.
TQ3Quaternion *Q3Quaternion_Set (
TQ3Quaternion *quaternion,
float w,
float x,
float y,
float z);
You can use the Q3Quaternion_SetIdentity function to set a quaternion to the identity quaternion.
TQ3Quaternion *Q3Quaternion_SetIdentity (
TQ3Quaternion *quaternion);
You can use the Q3Quaternion_Copy function to get a copy of a quaternion.
TQ3Quaternion *Q3Quaternion_Copy (
const TQ3Quaternion *quaternion,
TQ3Quaternion *result);
You can use the Q3Quaternion_IsIdentity function to determine whether a quaternion is the identity quaternion.
TQ3Boolean Q3Quaternion_IsIdentity (
const TQ3Quaternion *quaternion);
You can use the Q3Quaternion_Invert function to invert a quaternion.
TQ3Quaternion *Q3Quaternion_Invert (
const TQ3Quaternion *quaternion,
TQ3Quaternion *result);
You can use the Q3Quaternion_Normalize function to normalize a quaternion.
TQ3Quaternion *Q3Quaternion_Normalize (
const TQ3Quaternion *quaternion,
TQ3Quaternion *result);
You can use the Q3Quaternion_Dot function to determine the dot product of two quaternions.
float Q3Quaternion_Dot (
const TQ3Quaternion *q1,
const TQ3Quaternion *q2);
You can use the Q3Quaternion_Multiply function to multiply two quaternions.
TQ3Quaternion *Q3Quaternion_Multiply (
const TQ3Quaternion *q1,
const TQ3Quaternion *q2,
TQ3Quaternion *result);
The Q3Quaternion_Multiply function returns, as its function result and in the result parameter, the product of the two quaternions q1 and q2 .
If you want to rotate an object by the quaternion qFirst and then rotate the resulting object by the quaternion qSecond , you can accomplish both rotations at once by applying the quaternion qResult that is obtained as follows:
Q3Quaternion_Multiply(qSecond, qFirst, qResult);
You can use the Q3Quaternion_SetRotateAboutAxis function to configure a rotate-about-axis quaternion.
TQ3Quaternion *Q3Quaternion_SetRotateAboutAxis (
TQ3Quaternion *quaternion,
const TQ3Vector3D *axis,
float angle);
You can use the Q3Quaternion_SetRotate_X function to configure a quaternion that rotates objects around the x axis.
TQ3Quaternion *Q3Quaternion_SetRotate_X (
TQ3Quaternion *quaternion,
float angle);
You can use the Q3Quaternion_SetRotate_Y function to configure a quaternion that rotates objects around the y axis.
TQ3Quaternion *Q3Quaternion_SetRotate_Y (
TQ3Quaternion *quaternion,
float angle);
You can use the Q3Quaternion_SetRotate_Z function to configure a quaternion that rotates objects around the z axis.
TQ3Quaternion *Q3Quaternion_SetRotate_Z (
TQ3Quaternion *quaternion,
float angle);
You can use the Q3Quaternion_SetRotate_XYZ function to configure a quaternion having a specified rotation around the x, y, and z axes.
TQ3Quaternion *Q3Quaternion_SetRotate_XYZ (
TQ3Quaternion *quaternion,
float xAngle,
float yAngle,
float zAngle);
You can use the Q3Quaternion_SetMatrix function to configure a quaternion from a matrix.
TQ3Quaternion *Q3Quaternion_SetMatrix (
TQ3Quaternion *quaternion,
const TQ3Matrix4x4 *matrix);
You can use the Q3Quaternion_SetRotateVectorToVector function to configure a quaternion that rotates objects around the origin in such a way that a transformed vector matches a given vector.
TQ3Quaternion *Q3Quaternion_SetRotateVectorToVector (
TQ3Quaternion *quaternion,
const TQ3Vector3D *v1,
const TQ3Vector3D *v2);
You can use the Q3Quaternion_MatchReflection function to match the orientation of a quaternion.
TQ3Quaternion *Q3Quaternion_MatchReflection (
const TQ3Quaternion *q1,
const TQ3Quaternion *q2,
TQ3Quaternion *result);
The Q3Quaternion_MatchReflection function returns, as its function result and in the result parameter, a quaternion that is either identical to the quaternion specified by the q1 parameter or is the negative of q1 , depending on whether q1 or its negative matches the orientation of the quaternion specified by the q2 parameter.
You can use the Q3Quaternion_InterpolateFast function to interpolate quickly between two quaternions.
TQ3Quaternion *Q3Quaternion_InterpolateFast (
const TQ3Quaternion *q1,
const TQ3Quaternion *q2,
float t,
TQ3Quaternion *result);
The Q3Quaternion_InterpolateFast function returns, as its function result and in the result parameter, a quaternion that interpolates between the two quaternions specified by the q1 and q2 parameters, according to the factor specified by the t parameter. If the value of t is 0.0, Q3Quaternion_InterpolateFast returns a quaternion identical to q1 . If the value of t is 1.0, Q3Quaternion_InterpolateFast returns a quaternion identical to q2 . If t is any other value in the range [0.0, 1.0], Q3Quaternion_InterpolateFast returns a quaternion that is interpolated between the two quaternions.
The interpolation returned by Q3Quaternion_InterpolateFast is not as smooth or constant as that returned by Q3Quaternion_InterpolateLinear , but Q3Quaternion_InterpolateFast is usually faster than Q3Quaternion_InterpolateLinear .
You can use the Q3Quaternion_InterpolateLinear function to interpolate linearly between two quaternions.
TQ3Quaternion *Q3Quaternion_InterpolateLinear (
const TQ3Quaternion *q1,
const TQ3Quaternion *q2,
float t,
TQ3Quaternion *result) ;
The Q3Quaternion_InterpolateLinear function returns, as its function result and in the result parameter, a quaternion that interpolates smoothly between the two quaternions specified by the q1 and q2 parameters, according to the factor specified by the t parameter. If the value of t is 0.0, Q3Quaternion_InterpolateLinear returns a quaternion identical to q1 . If the value of t is 1.0, Q3Quaternion_InterpolateLinear returns a quaternion identical to q2 . If t is any other value in the range [0.0, 1.0], Q3Quaternion_InterpolateLinear returns a quaternion that is interpolated between the two quaternions in a smooth and constant manner.
You can use the Q3Vector3D_TransformQuaternion function to transform a vector by a quaternion.
TQ3Vector3D *Q3Vector3D_TransformQuaternion (
const TQ3Vector3D *vector,
const TQ3Quaternion *quaternion,
TQ3Vector3D *result);
You can use the Q3Point3D_TransformQuaternion function to transform a point by a quaternion.
TQ3Point3D *Q3Point3D_TransformQuaternion (
const TQ3Point3D *point,
const TQ3Quaternion *quaternion,
TQ3Point3D *result);
Previous | QD3D Book | Overview | Chapter Contents | Next |